home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / UUPC11QS.ARJ / MKDIR.C < prev    next >
C/C++ Source or Header  |  1991-11-21  |  2KB  |  63 lines

  1. /*--------------------------------------------------------------------*/
  2. /*    m k d i r . c                                                   */
  3. /*                                                                    */
  4. /*    Support routines for UUPC/extended                              */
  5. /*                                                                    */
  6. /*    Changes Copyright 1990, 1991 (c) Andrew H. Derbyshire           */
  7. /*                                                                    */
  8. /*    History:                                                        */
  9. /*       21Nov1991 Break out of lib.c                          ahd    */
  10. /*--------------------------------------------------------------------*/
  11.  
  12. #include <direct.h>
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <string.h>
  16. #include <time.h>
  17.  
  18. /*--------------------------------------------------------------------*/
  19. /*                    UUPC/extended include files                     */
  20. /*--------------------------------------------------------------------*/
  21.  
  22. #include "lib.h"
  23.  
  24. currentfile();
  25.  
  26. /*--------------------------------------------------------------------*/
  27. /*    M K D I R                                                       */
  28. /*                                                                    */
  29. /*    Like mkdir() but create intermediate directories as well        */
  30. /*--------------------------------------------------------------------*/
  31.  
  32. int MKDIR(const char *inpath)
  33. {
  34.    char *cp;
  35.    char *path;
  36.  
  37.    if (*inpath == '\0')
  38.       return 0;
  39.  
  40.    path = strdup(inpath);
  41.    checkref(path);
  42.    cp = path ;
  43.  
  44.    while ((cp = strchr(cp, '\\')) != nil(char)) {
  45.       *cp = '/';
  46.    }
  47.  
  48.    /* see if we need to make any intermediate directories */
  49.    cp = path ;
  50.    while ((cp = strchr(cp, '/')) != nil(char)) {
  51.       *cp = '\0';
  52.       mkdir(path);
  53.       *cp = '/';
  54.       cp++;
  55.    }
  56.  
  57.    free(path);
  58.  
  59.    /* make last dir */
  60.    return mkdir(inpath);
  61.  
  62. } /*MKDIR*/
  63.